﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project.MVC.Model;
using Project.MVC.MsSQLDAL;
namespace Project.MVC.Service
{
    public class UserServices : IUserServices
    {
        IUserRepository repository = null;
        public UserServices()
            : this(new UserRepository())
        {
        }

        public UserServices(IUserRepository rep)
        {
            repository = rep;
            if (repository == null)
                throw new InvalidOperationException("Repository cann't be null");
        }
        public IQueryable<UserInfo> GetList2Grid()
        {
            return repository.GetList();
        }

        public List<UserInfo> GetList()
        {
            return repository.GetList().ToList();
        }

        public List<UserInfo> GetList(int start, int offset)
        {
            throw new NotImplementedException();
        }

        public bool Insert(UserInfo value)
        {
            return repository.Insert(value);
        }

        public bool Update(UserInfo value)
        {
            return repository.Update(value);
        }

        public bool Delete(UserInfo value)
        {
            return repository.Delete(value);
        }

        public void SaveChange()
        {
            repository.Commit();
        }

        public int Count()
        {
           return repository.Count();
        }
    }
}
